package com.study.manage.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class ExcelData implements Serializable {

    private static final long serialVersionUID = 4444017239100620999L;

    // 表头
    private List<String> titles = new ArrayList<String>();

    // 数据
    private List<List<Object>> rows = new ArrayList<List<Object>>();

    // 页签名称
    private String name;

    public List<String> getTitles() {
        return titles;
    }

    public void setTitles(List<String> titles) {
        this.titles = titles;
    }

    public List<List<Object>> getRows() {
        return rows;
    }

    public void setRows(List<List<Object>> rows) {
        this.rows = rows;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public void addRowsData(String title, int row, Object value) {
        if (rows.size() <= row) {
            List<Object> arra = new ArrayList<>();
            for (String t : titles) {
                arra.add("");
            }
            rows.add(arra);
        }
        int titleIndex = this.titles.indexOf(title);
        if (titleIndex != -1) {
            this.rows.get(row).set(titleIndex, value);
        }
    }

}
